fix(typescript-fetch): support non-default file names#24006
Conversation
|
/cc typescript tech committee: @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @dennisameling |
There was a problem hiding this comment.
3 issues found across 126 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/client/petstore/typescript-fetch/builds/kebab-case/docs/EnumClass.md">
<violation number="1" location="samples/client/petstore/typescript-fetch/builds/kebab-case/docs/EnumClass.md:16">
P2: EnumClass doc example uses object literal for a string union enum type, producing non-compilable TypeScript</violation>
</file>
<file name="samples/client/petstore/typescript-fetch/builds/kebab-case/docs/Capitalization.md">
<violation number="1" location="samples/client/petstore/typescript-fetch/builds/kebab-case/docs/Capitalization.md:19">
P2: Generated model doc contains an empty module specifier in the TypeScript example (`from ''`) because the build config does not set `npmName`, leaving the `model_doc.mustache` template variable unresolved.</violation>
</file>
<file name="samples/client/petstore/typescript-fetch/builds/kebab-case/docs/FormatTest.md">
<violation number="1" location="samples/client/petstore/typescript-fetch/builds/kebab-case/docs/FormatTest.md:45">
P2: UUID example value is emitted without quotes, resulting in invalid TypeScript syntax for a string field.</violation>
</file>
Note: This PR contains a large number of files. cubic only reviews up to 100 files per PR, so some files may not have been reviewed. cubic prioritizes the most important files to review.
On a pro plan you can use ultrareview for larger PRs.
Re-trigger cubic
| import type { EnumClass } from '' | ||
|
|
||
| // TODO: Update the object below with actual values | ||
| const example = { |
There was a problem hiding this comment.
P2: EnumClass doc example uses object literal for a string union enum type, producing non-compilable TypeScript
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-fetch/builds/kebab-case/docs/EnumClass.md, line 16:
<comment>EnumClass doc example uses object literal for a string union enum type, producing non-compilable TypeScript</comment>
<file context>
@@ -0,0 +1,32 @@
+import type { EnumClass } from ''
+
+// TODO: Update the object below with actual values
+const example = {
+} satisfies EnumClass
+
</file context>
| ## Example | ||
|
|
||
| ```typescript | ||
| import type { Capitalization } from '' |
There was a problem hiding this comment.
P2: Generated model doc contains an empty module specifier in the TypeScript example (from '') because the build config does not set npmName, leaving the model_doc.mustache template variable unresolved.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-fetch/builds/kebab-case/docs/Capitalization.md, line 19:
<comment>Generated model doc contains an empty module specifier in the TypeScript example (`from ''`) because the build config does not set `npmName`, leaving the `model_doc.mustache` template variable unresolved.</comment>
<file context>
@@ -0,0 +1,44 @@
+## Example
+
+```typescript
+import type { Capitalization } from ''
+
+// TODO: Update the object below with actual values
</file context>
| "binary": null, | ||
| "date": null, | ||
| "dateTime": null, | ||
| "uuid": 72f98069-206d-4f12-9f12-3d1e525a8e84, |
There was a problem hiding this comment.
P2: UUID example value is emitted without quotes, resulting in invalid TypeScript syntax for a string field.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-fetch/builds/kebab-case/docs/FormatTest.md, line 45:
<comment>UUID example value is emitted without quotes, resulting in invalid TypeScript syntax for a string field.</comment>
<file context>
@@ -0,0 +1,64 @@
+ "binary": null,
+ "date": null,
+ "dateTime": null,
+ "uuid": 72f98069-206d-4f12-9f12-3d1e525a8e84,
+ "password": null,
+ "patternWithDigits": null,
</file context>
files generated with non-default (e.g. "fileNaming": "kebab-case") have their import path set with the default file name. this PR fixes the non-barrel imports by using the parsed file name instead of simply the class name.
(fixes #23840)
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
Summary by cubic
Fixes broken model imports in the
typescript-fetchgenerator whenfileNamingis non-default (e.g., kebab-case). API files now import models using the actual generated file name instead of the class name.classFileName(viaconvertUsingFileNamingConvention) for model import paths inapis.mustacheandsagas.mustacheto support non-defaultfileNaming.TypeScriptFetchClientCodegenTestto assert kebab-case imports (e.g.,../models/petnot../models/Pet) and setWITHOUT_RUNTIME_CHECKSto false to exercise imports.bin/configs/typescript-fetch-kebab-case.yamland regenerated samples undersamples/client/petstore/typescript-fetch/builds/kebab-casefor coverage.Written for commit 80e5496. Summary will update on new commits.